package com.example.homework2;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class RecyclerView_Adapter extends RecyclerView.Adapter<RecyclerView_Adapter.View_Holder> {

    List<Integer> num = new ArrayList<>();

    public RecyclerView_Adapter(List<Integer> num) {
        this.num = num;
    }

    @NonNull
    @Override
    public View_Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new View_Holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull View_Holder holder, int position) {
        holder.title.setText("Title:" + num.get(position));
        holder.content.setText("Content:" + num.get(position));
    }

    @Override
    public int getItemCount() {
        return num.size();
    }

    public class View_Holder extends RecyclerView.ViewHolder {
        public TextView title, content;

        public View_Holder(View itemView) {
            super(itemView);
            title = itemView.findViewById(R.id.title);
            content = itemView.findViewById(R.id.content);
        }
    }
}
